<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>#{bundle.bvtype}</title>
        <link href="./resources/css/default.css" rel="stylesheet" type="text/css" />
    </h:head>
    <h:body>
        <ui:composition>
        <h:form >

           <script type="text/javascript">  
                function handleSaveRequest(xhr, status, args) {  
                    if(args.validationFailed || !args.success) {  
                        jQuery('#dialog').effect("shake", { times:3 }, 100);  
                    } else {  
                        dlgBvtype.hide();  
                    }  
                }
                
                function handleDeleteRequest(xhr, status, args) {  
                    if(args.validationFailed || !args.success) {  
                        jQuery('#dialog').effect("shake", { times:3 }, 100);  
                    } else {  
                        dlgDelBVtype.hide();  
                    }  
                }
                
            </script>  

            <p:toolbar>
                <p:toolbarGroup align="left">
                    <p:commandButton value="#{bundle.btnNew}" icon="ui-icon-document"
                                     action="#{bvtypeBean.newData()}"  
                                     oncomplete="dlgBvtype.show()"
									 rendered="#{menuBean.cekButtonAccess(463,'INS;')}"
                                     update=":#{utilityBean.findClientId('displayBvtype')}"> 
                    </p:commandButton>

                    <p:commandButton value="#{bundle.btnOpen}" oncomplete="dlgBvtype.show()"
                                     action="#{bvtypeBean.openData()}"  
                                     icon="ui-icon-disk" rendered="#{menuBean.cekButtonAccess(463,'OPN;')}"
                                     update=":#{utilityBean.findClientId('displayBvtype')}" > 
                    </p:commandButton>

                    <p:commandButton value="#{bundle.btnDelete}" icon="ui-icon-trash"
                                     onclick="dlgDelBVtype.show()" rendered="#{menuBean.cekButtonAccess(463,'DEL;')}" />

                    <!-- <p:commandButton type="push" value="#{bundle.btnPrint}" icon="ui-icon-print"/> -->
                </p:toolbarGroup>
            </p:toolbar>
            <br />
            <p:dataTable var="bvt" value="#{bvtypeBean.bvtypes}" id="dtBvtypes" resizableColumns="true"
                         rowIndexVar="noUrut" selection="#{bvtypeBean.selectedData}" selectionMode="single" rowKey="#{bvt.bvtypeId}" >
                 <p:column style="width: 15px">
                    <f:facet name="header">No.</f:facet>
                    <h:outputText value="#{noUrut+1}" />
                 </p:column>
                <p:column style="width:200px" >
                    <f:facet name="header">#{bundle.globalName}</f:facet>
                    <h:outputText value="#{bvt.typeName}" />
                </p:column>
            </p:dataTable>
          
            <p:confirmDialog message="#{bundle.confirmDelete}" appendToBody="true" 
                             header="#{bundle.confirmDeleteHeader}" severity="alert" widgetVar="dlgDelBVtype">
                <h:panelGrid cellspacing="0" cellpadding="0" styleClass="pComBtnD">
                    <f:facet name="footer">
                        <p:commandButton value="#{bundle.btnYes}" update="dtBvtypes" process="@this"
                                         oncomplete="handleDeleteRequest(xhr, status, args)"  
                                         actionListener="#{bvtypeBean.delete()}" />  
                        <p:commandButton value="#{bundle.btnCancel}" onclick="dlgDelBVtype.hide()" type="button" />
                    </f:facet>
                </h:panelGrid>   
            </p:confirmDialog> 

        </h:form>
            <p:dialog header="#{bundle.bvtype}" widgetVar="dlgBvtype" closable="true"
                      dynamic="true" modal="true" appendToBody="true">
                <p:ajax event="close" listener="#{bvtypeBean.handleClose}"/>
                <h:form>
                <h:panelGrid id="displayBvtype" columns="2" styleClass="addELIT">
                    <h:outputLabel style="padding: 0 15px 0 0" value= "#{bundle.globalName} :" />
                    <p:inputText rendered="#{bvtypeBean.insertedData!=null}" value="#{bvtypeBean.insertedData.typeName}" 
                                     required="true" label="#{bundle.globalName}" size="25" />  
                    
                    <h:outputLabel style="padding: 0 15px 0 0" value= "#{bundle.position} :" />
                    <p:selectOneRadio rendered="#{bvtypeBean.insertedData!=null}" value="#{bvtypeBean.insertedData.position}">
                        <f:selectItem itemLabel="#{bundle.bvcredit}" itemValue="1" />
                        <f:selectItem itemLabel="#{bundle.bvdebit}" itemValue="2" />
                    </p:selectOneRadio>
                </h:panelGrid>
                <h:panelGrid cellpadding="0" styleClass="pComBtnSTDR">
                    <f:facet name="footer">
                        <p:commandButton value="#{bundle.btnSave}" icon="ui-icon-disk" actionListener="#{bvtypeBean.save()}" rendered="#{menuBean.cekButtonAccess(463,'UPD;')}"
                                         update=":#{utilityBean.findClientId('dtBvtypes')}"
                                         oncomplete="handleSaveRequest(xhr, status, args)"/>
                        <p:commandButton value="#{bundle.btnClose}" oncomplete="dlgBvtype.hide()" icon="ui-icon-document"/>
                    </f:facet>
                </h:panelGrid>
                    </h:form>
            </p:dialog> 
        
        </ui:composition>    
    </h:body>
</html>
